package com.julian.templatePattern;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TeaWithHook extends CaffeeineBeverageWithHook {
    @Override
    protected void addCondients() {
        System.out.println("Adding Lemon");
    }

    @Override
    protected void brew() {
        System.out.println("Brew Teat into cap");
    }

    protected  String getUserInput(){
        String answer = null;
        System.out.println("Would u like lemon with u tea(y/n)");
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            answer = in.readLine();
        }catch (IOException e){
            System.err.println("IO ERROR Trying to read your answer");
        }
        if (answer == null) {
            return "no";
        }
        return answer;
    }

    @Override
    protected boolean customerWantsCondients(){
        String answer = getUserInput();
        if (answer.toLowerCase().startsWith("y")){
            return true;
        }
        return false;
    }
}
